package other_其他模式.front_controller_pattern_前端控制器模式;

import java.time.LocalDateTime;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: hihi
 * @Date: 2020/07/10/11:23
 * @Description:
 */
public class FrontController {

	private Dispatcher dispatcher;

	public FrontController() {
		dispatcher = new Dispatcher();
	}

	private boolean isAuthenticUser() {
		System.err.println("Authentic success");
		return true;
	}

	private void tracerRequest(String request) {
		System.err.println(LocalDateTime.now() + " : tracer request : " + request);
	}

	public void dispatcherRequest(String request) {
		//记录
		tracerRequest(request);

		//认证
		if (isAuthenticUser()) {
			//调度器处理
			dispatcher.dispatcher(request);
		}

	}
}
